/*
 * IJA2011, Board game "Clovece nezlob se"
 * grp108
 * Tomáš Mičiak,xmicia00
 * Andrej Martinák, xmarti51
 *
 */

package src.clovece.game;

import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

/**
 *  Class representing game field
 */
public class GameField extends JLabel implements MouseListener {
    private GameManagement gameManagement = GameManagement.getGameManagementInstance();
    private int color;
    private boolean saveHouse = false;
    private ArrayList<Integer> moveAllowed = new ArrayList<Integer>();
    private int position;
    private boolean occupied = false;

    public GameField(int gameSet, int color, int i) {
        this.color = color;
        this.position = i;
        ImageIcon icon = new ImageIcon(System.getProperty("user.dir")+ System.getProperty("file.separator")
                  + "lib" + System.getProperty("file.separator") + "img"
                  + System.getProperty("file.separator") + gameSet + color + ".png");
        this.setIcon(icon);
    }

    public void paintMoveAllowed() {
        this.setOpaque(true);
        this.setBackground(Color.green);
        this.repaint();
    }

    public void unColor() {
        this.setOpaque(false);
        this.repaint();
    }

    public int getColor() {
        return this.color;
    }

    public int getPosition() {
        return this.position;
    }

    public void setSaveHouse(boolean flag) {
        this.saveHouse = flag;
    }

    public boolean getSaveHouse() {
        return this.saveHouse;
    }

    public void addMoveAllowed(int figurine) {
        this.moveAllowed.add(new Integer(figurine));
    }
    
    public void setMoveAllowed(ArrayList<Integer> list) {
        this.moveAllowed = list;
    }

    public ArrayList<Integer> getMoveAllowed() {
        return this.moveAllowed;
    }

    public void setOccupied(boolean flag) {
        this.occupied = flag;
    }

    public boolean getOccupied() {
        return this.occupied;
    }

    public void mouseClicked(MouseEvent e) {
        System.out.println(this.getPosition());
        this.gameManagement.moveFigurine(this);
    }

    public void mousePressed(MouseEvent e) {
    }

    public void mouseReleased(MouseEvent e) {
    }

    public void mouseEntered(MouseEvent e) {
    }

    public void mouseExited(MouseEvent e) {
    }

}
